package com.majunpeng.activemq;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class Producer {
    public static void main(String[] args) throws JMSException {
        System.out.println("producer");

        //创建工厂
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnectionFactory.DEFAULT_BROKER_URL);

        //获取连接
        Connection connection = connectionFactory.createConnection();

        //获取session
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        Queue queue = session.createQueue("user");

        MessageProducer producer = session.createProducer(queue);

        Message message = session.createTextMessage("hi");

        producer.send(message);

        System.out.println("send message end");
    }
}
